<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
	<title>前锋图书馆</title>
	<link rel="stylesheet" type="text/css" href="/css/index.css">
	<link rel="stylesheet" type="text/css" href="/css/base.css" />
	<style type="text/css">
		.headerWrap{width: 100%;height: 33px;background-color: #F7F7F7;}
		.header{width: 1250px;height: 100%;margin: 0 auto;}
		.logoimg{float: left;padding-top: 7px;}
		.logoimg i{float: left;width: 18px;height: 18px;margin-right: 4px;background-position: 0 0;}
		.sprite{background-image: url("/img/index.png");}
		i{display: block;}
		.headerright{float: right;margin-right: 20px;}
		.headercon{float: left;padding: 6px 20px 0px;font-size: 15px;cursor: pointer;}
		.headercon:hover{color: #D61A0B;}
		.headerright li{display: inline-block!important;}
		.navWrap{width: 100%;height: 50px;background-color: #fff;border-bottom: 1px solid #E7E7E7;}
		.nav{width: 1250px;height: 100%;margin: 0 auto;line-height: 50px;}
		.navli{float: left;margin-right: 50px;}
		.navli i{width: 100%;}
		.navlicon{font-size: 15px;}
		.navli:hover{border-bottom: 2px solid #D61A0B;cursor: pointer;}
		.navlicon:hover{color: #D61A0B;cursor: pointer;}
		.navline{width: 0;height: 2px;position: absolute;left: 0;bottom: 0;background-color: #C7332E;}
		.searchbox{width: 280px;height: 32px;float: right;margin-top: 9px;box-sizing: border-box;border: 1px solid #eaeaea;border-radius: 20px;    background-color: #f5f5f5;position: relative;overflow: hidden;margin-right: 40px;}
		.search{width: 230px;height: 30px;line-height: 30px;font-size: 14px;color: #333;position: absolute;left: 0;top: 1px;background-color: #f5f5f5;
    box-sizing: border-box;padding: 0 0 0 15px;}
    	.search_icon_container{width: 50px;height: 30px;position: absolute;right: 0;top: 1px;cursor: pointer;}
    	.search_icon{width: 14px;height: 14px;background-repeat: no-repeat;background-position: -60px -50px;margin: 7px auto;}
    	.shownav{border-bottom: 2px solid #D61A0B;}
    	.shownavli{color: #D61A0B;}
	</style>
</head>
<body>
	<div class="big">
	<!-- 头部 -->
  		<!-- title部分 -->
		<div class="title">

			<div class="headerWrap">
				<div class="header">
					<div class="logoimg">
						<i class="sprite"></i>
						<span class="headerLogoCon">前锋图书馆</span>
					</div>
					<div class="headerright">
						<div class="headercon">您好！{$uname|default='请登录'}</div>
						<div class="headercon applyrule">借阅规则</div>
						<a href="/index/personalcenter/index"><div class="headercon">个人中心</div></a>
						<a href="/index/index/logout"><div class="headercon">退出登录</div></a>
					</div>
				</div>
			</div>
			<div class="navWrap">
				<div class="nav">
					<div class="navli shownav">
						<div class="navlicon shownavli">馆内图书</div>
						<!-- <i class="navline"></i> -->
					</div>
					<div class="navli">
						<div class="navlicon">未借出图书</div>
						<!-- <i class="navline"></i> -->
					</div>
					<div class="navli">
						<div class="navlicon">已借出图书</div>
						<!-- <i class="navline"></i> -->
					</div>
					<div class="searchbox">
						<input type="text" name="" class="search" id="bname" placeholder=" 请输入书籍名称">
						<div class="search_icon_container">
							<div class="search_icon sprite" title="搜索"></div>
						</div>
					</div>
				</div>
			</div>
			
		</div>
		<!-- middle部分 -->
		
		<!-- list部分 -->
		<form>
		<div class="list">
			<div class="shangyan">

				<!-- <div class="shang_title">
					<div class="librarybooks contentTitle checked"><span class="contentTiltleinfo">馆内图书</span></div>
					<div class="lendbooks contentTitle"><span class="contentTiltleinfo">未借出图书</span></div>
					<div class="overdue contentTitle"><span class="contentTiltleinfo">已借出图书</span></div>
				</div> -->

				<div class="shang_content">
					{if condition="!empty($books)"}
					<div class="contentWarp">
						<div class="content"></div>
					</div>
					<div class="contentWarp hidden">
						<div class="content1"></div>
					</div>
					<div class="contentWarp hidden">
						<div class="content2"></div>
					</div>
					{/if}
					<div class="page_control">
						<div class="paginationOut">
							<div class="pagination1 hidden"></div>
							<div class="pagination2 hidden"></div>
							<div class="pagination3 hidden"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		</form>
		<!-- 底部 -->
		<div class="floor">
			<div class="floor_min">
				<div class="floor_min_bottom">
					<span style="text-align: center;">&copy;前锋图书管理系统</span>
				</div>
			</div>
		</div>
		<div class="ruleAll hidden"></div>
		<div class="needread hidden">
			<div class="needKnow">
				<ul>
					<li>借阅规则：</li>
					<li>1.借阅书籍周期为15天，每人每次只允许借阅一本。</li>
					<li>2.续借图书优先级低于预约图书（例：借阅期未读完想续借，已被人预约，必须归还）。</li>
					<li>3.个人提供书籍可随时取走（该书籍还在节约中，私下解决）。</li>
					<li>4.借阅图书出现破损，视破损程度决定是否赔偿（书籍不得勾画）。</li>
					<li>5.工作时间不得阅读与工作无关书籍。</li>
					<li>6.逾期3天内未还借阅系统通报批评一周，超过3天进入到下一轮购书序列缴费名单。</li>
					<li>7.遗失书籍需要赔偿相同新书一本。</li>
					<li>8.团购书籍最终归属该轮购买团队最后一人所有。</li>
					<li>9.以上借阅规则最终解释权归研发团队所有。</li>
				</ul>
			</div>
		</div>
		<div class="close hidden">关闭</div>
	</div>
</body>
<script src="/js/jquery.js"></script>
<script src="/js/layer/layer.js"></script>
<script src="/js/jquery.paging.js"></script>
<script type="text/javascript">
//点击显示规则
$(".applyrule").click(function(){
	$(".ruleAll").removeClass('hidden');
	$(".needread").removeClass('hidden');
	$(".close").removeClass('hidden');
})
//点击隐藏规则
$(".close").click(function(){
	$(".ruleAll").addClass('hidden');
	$(".needread").addClass('hidden');
	$(".close").addClass('hidden');
})
$(function(){
	var tabBtnNum=0;
	$(".navli").click(function(){
		tabBtnNum=$(this).index();
		
		$(".contentWarp").addClass('hidden');
		$(".contentWarp").eq(tabBtnNum).removeClass('hidden');
		$(".navli").removeClass('shownav');
		$(".navlicon").removeClass('shownavli');
		$(".navli").eq(tabBtnNum).addClass('shownav');
		$(".navlicon").eq(tabBtnNum).addClass('shownavli');
		if(tabBtnNum==0){
			$(".pagination1").empty();
			$(".pagination2").empty();
			$(".pagination3").empty();
			$(".pagination2").hide();
			$(".pagination3").hide();
			page1();
		}else if(tabBtnNum==1){
			$(".pagination1").empty();
			$(".pagination2").empty();
			$(".pagination3").empty();
			$(".pagination1").hide();
			$(".pagination3").hide();
			page2();
		}else if(tabBtnNum==2){
			$(".pagination1").empty();
			$(".pagination2").empty();
			$(".pagination3").empty();
			$(".pagination2").hide();
			$(".pagination1").hide();
			page3();
		}
	});
})
</script>
<script>
//申请借阅
var bnum;
$(".content1").on('click','.applyBtn',function(){
	bnum = $(this).index('.applyBtn');
	// alert(bnum);
	var bookid = $(this).find('input').val();
	// alert(bookid);
	$.ajax({
        type: "POST",
        url: "/index/screendetails/doapply",
        data: {'bookid': bookid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){

            	layer.alert('墨绿风格，点击确认看深蓝', {
				  skin: 'layui-layer-molv' //样式类名
				  ,closeBtn: 0
				}, function(){
				  layer.alert('偶吧深蓝style', {
				    skin: 'layui-layer-lan'
				    ,closeBtn: 0
				    ,anim: 4 //动画类型
				  });
				});



                // layer.alert('已申请！', {
                //     icon: 1,
                //     time: 1000
                // }, function () {
                // 	var bhtml = '';
                // 	bhtml += '<div class="applysBtn">';
                // 	bhtml += '<span class="applysBtninfo"><input type="hidden" class="bookid" value="'+bookid+'">已申请(点击取消)</span></div>';
                //     $(".applyBtn").eq(bnum).replaceWith(bhtml);
                // });
            }else{
                layer.msg('申请失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//取消申请
var bnums;
$(".content1").on('click','.applysBtn',function(){
	bnums = $(this).index('.applysBtn');
	// alert(bnums);
	var bookid = $(this).find('input').val();
	// alert(bookid);
	$.ajax({
        type: "POST",
        url: "/index/screendetails/cancelapply",
        data: {'bookid': bookid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('取消成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applyBtn">';
                	bhtml += '<span class="applyBtninfo"><input type="hidden" class="bookid" value="'+bookid+'">申请借阅</span></div>';
                    $(".applysBtn").eq(bnums).replaceWith(bhtml);
                });
            }else{
                layer.msg('取消失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//预约书籍
var wantnum;
$(".content2").on('click','.applyBtn1',function(){
	wantnum = $(this).index('.applyBtn1');
	// alert(wantnum);
	var booksid = $(this).find('input').val();
	$.ajax({
        type: "POST",
        url: "/index/screendetails/doapplys",
        data: {'bookid': booksid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('预约成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applysBtn1">';
                	bhtml += '<span class="applysBtninfo1"><input type="hidden" class="booksid" value="'+booksid+'">已预约(点击取消)</span></div>';
                    $(".applyBtn1").eq(wantnum).replaceWith(bhtml);
                });
            }else{
                layer.msg('预约失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//取消预约
var wantnums;
$(".content2").on('click','.applysBtn1',function(){
	wantnums = $(this).index('.applysBtn1');
	// alert(wantnums);
	var booksid = $(this).find('input').val();
	// alert(booksid);
	$.ajax({
        type: "POST",
        url: "/index/screendetails/cancelapplys",
        data: {'bookid': booksid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('取消成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applyBtn1">';
                	bhtml += '<span class="applyBtninfo1"><input type="hidden" class="booksid" value="'+booksid+'">预约</span></div>';
                    $(".applysBtn1").eq(wantnums).replaceWith(bhtml);
                });
            }else{
                layer.msg('取消失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//归还申请
var applyNum;
$('.content2').on('click','.applyssBtn1',function(){
	applyNum = $(this).index('.applyssBtn1');
	var id = $(this).find('input').val();
	// alert(id);
	$.ajax({
	    type: "POST",
	    url: "/index/screendetails/applyrollback",
	    data: {'id': id},
	    dataType: "json",
	    timeout: 3000,
	    success: function (data) {
	        console.log(data)
	        if(data>=1){
	            layer.msg('申请已提交，请等待处理！', {
	                icon: 1,
	                time: 1000
	            }, function () {
	                var bhtml = '';
                	bhtml += '<div class="applysssBtn1">';
                	bhtml += '<span class="applysssBtninfo1"><input type="hidden" class="booksid" value="'+id+'">正在处理</span></div>';
                    $(".applyssBtn1").eq(applyNum).replaceWith(bhtml);
	            });
	        }else{
	            layer.msg('申请失败！', {
                    icon: 2,
                    time: 1000
                }); 
	       	}
	    }
    });
});
</script>
<script>
$(function(){
	page1();
})
//馆内图书分页
function page1(){
	$('.pagination1').paging({
	    total: '',
	    currentPage: '',
	    showPage: 5,        //显示的页数
	    animation: false,
	    showJump: false,
	    ajaxSubmitType: 'post',
	    simpleType: 1,
	    url: '/index/screendetails/pageBookRecordss',
	    idParameter: "page",
	    ajaxData: {'pageType': 1},
	    beforeAjaxSubmit: function () {
	        PageAPI.AddAjaxData({"pageSize": $(".pageSize").val()});
	    },
	    ajaxSubmitBack: function (data) {
	        $('.content').empty();
	        var orderinfo = data.data;
	        console.log(orderinfo);
	        if(orderinfo=='' ||orderinfo==undefined){
	            $(".content").html(' <h2 style="text-align: center;padding-top:120px;height: 166px;color: red; background-color: #fff;">暂无数据</h2>');
	            $(".pagination").hide();
	        }else{
	            $(".pagination").show();
	            var infohtml="";
	            $(orderinfo).each(function(i,val){ 
	        		infohtml+='<div class="contents">';
			        infohtml+='<div class="booksWrap1">';
			        if (val.img&&val.img!='') {
				        infohtml+='<div class="booksImg"><img src="'+val.img+'" class="bookImg"></div>';
				    }else{
				        infohtml+='<div class="booksImg"><img src="/img/replace.jpg" class="bookImg"></div>';
				    }
			        infohtml+='<div class="booksName1">';
			        if (val.bname&&val.bname!='') {
			        	infohtml+='<span class="bookNameinfo1" title="《'+val.bname+'》">《'+val.bname+'》</span></div>';
			        }else{
			        	infohtml+='<span class="bookNameinfo1">暂无书名</span></div>';
			        }
			        infohtml+='<div class="booksPeople">';
			        if (val.uname&&val.uname!='') {
			        	infohtml+='<span class="booksPeopleinfo">借阅人：'+val.uname+'</span></div>'; 
			        }else{
			        	infohtml+='<span class="bookNameinfo1">借阅人：暂无</span></div>';
			        }
					infohtml+='<div class="booksTime">';
					if (val.booktime&&val.booktime!='') {
			        	infohtml+='<span class="booksTimeinfo">借阅时间：'+val.booktime+'-'+val.expectedReturnTime+'</span></div>';
			        }else{
			        	infohtml+='<span class="booksTimeinfo">借阅时间：暂无</span></div>';
			        }
			        if(val.overtime&&val.overtime!=0){
			        	infohtml+='<div class="booksTime2">'; 
						infohtml+='<span class="booksPeopleinfo2">逾期时间：'+val.overtime+'天</span></div>'; 
			        }else{
			        	infohtml+='<div class="booksTime2">'; 
						infohtml+='<span class="booksPeopleinfo2">逾期时间：暂无</span></div>'; 
			        }
			        if(val.apply==1){
				        infohtml+='<div class="applysBtn">';
				        infohtml+='<span class="applysBtninfo"><input type="hidden" class="bookid" value="'+val.id+'">已申请(点击取消)</span></div>';
				    }else if(val.apply==0){
				        infohtml+='<div class="applyBtn">';
				        infohtml+='<span class="applyBtninfo"><input type="hidden" class="bookid" value="'+val.id+'">申请借阅</span></div>';
				    }else if(val.power==1&&val.states!=6){
			        	infohtml+='<div class="applyssBtn1">';
			        	infohtml+='<span class="applyssBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">申请归还</span></div>';
			        }else if(val.power==1&&val.states==6){
			        	infohtml+='<div class="applysssBtn1">';
			        	infohtml+='<span class="applysssBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">正在处理</span></div>';
			        }else if(val.type==1){
			        	infohtml+='<div class="applysBtn1">';
			        	infohtml+='<span class="applysBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">已预约(点击取消)</span></div>';
			        }else if(val.type==0){
			        	infohtml+='<div class="applyBtn1">';
			        	infohtml+='<span class="applyBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">预约</span></div>';
			        }
			        infohtml+='</div></div>';
		        });
		        $(".content").html(infohtml);
		        var info='<div class="clearfloat"></div>';
		        $(".content").append(info);
		        $(".pagination1").show();
	        }
	    },
	    ajaxFormatBack: function (data) {
	        data.total = data.totalpage;
	        data.currentPage = data.currentPage;
	    }
	});
}

//未借图书分页
function page2(){
	$('.pagination2').paging({
	    total: '',
	    currentPage: '',
	    showPage: 5,        //显示的页数
	    animation: false,
	    showJump: false,
	    ajaxSubmitType: 'post',
	    simpleType: 1,
	    url: '/index/screendetails/pageBookRecord',
	    idParameter: "page",
	    ajaxData: {'pageType': 1},
	    beforeAjaxSubmit: function () {
	        PageAPI.AddAjaxData({"pageSize": $(".pageSize").val()});
	    },
	    ajaxSubmitBack: function (data) {
	        console.log(data);
	        $('.content1').empty();
	        var orderinfo = data.data;
	        console.log(orderinfo);
	        var infohtml='';	
	        if(orderinfo=='' ||orderinfo==undefined){
	            $(".content1").html(' <h2 style="text-align: center;padding-top:120px;height: 166px;color: red;background-color:#fff;">暂无数据</h2>');
	            $(".pagination1").hide();
	        }else{
	        	$(orderinfo).each(function(i,val){   
					if(val.bstates==1){	
						infohtml+='<div class="contents">';
				        infohtml+='<div class="booksWrap">';
				        if (val.img&&val.img!='') {
				        	infohtml+='<div class="booksImg"><img src="'+val.img+'" class="bookImg"></div>';
				        }else{
				        	infohtml+='<div class="booksImg"><img src="/img/replace.jpg" class="bookImg"></div>';
				        }
				        infohtml+='<div class="booksName">';
				        if (val.bname&&val.bname!='') {
				        	infohtml+='<span class="bookNameinfo" title="《'+val.bname+'》">《'+val.bname+'》</span></div>';
				        }else{
				        	infohtml+='<span class="bookNameinfo">暂无书名</span></div>';
				        }
				        if(val.type==1){
				            infohtml+='<div class="applysBtn">';
				            infohtml+='<span class="applysBtninfo"><input type="hidden" class="bookid" value="'+val.id+'">已申请(点击取消)</span></div>';
				        }else{
				            infohtml+='<div class="applyBtn">';
				            infohtml+='<span class="applyBtninfo"><input type="hidden" class="bookid" value="'+val.id+'">申请借阅</span></div>';
				        }
				        infohtml+='</div></div>';
					}
		        });
		        $(".content1").html(infohtml);
		        var info='<div class="clearfloat"></div>';
		        $(".content1").append(info);
		        $(".pagination2").show();
	        }
	    },
	    ajaxFormatBack: function (data) {
	        data.total = data.totalpage;
	        data.currentPage = data.currentPage;
	    }
	});
}

//借出图书分页
function page3(){
	$('.pagination3').paging({
	    total: '',
	    currentPage: '',
	    showPage: 5,        //显示的页数
	    animation: false,
	    showJump: false,
	    ajaxSubmitType: 'post',
	    simpleType: 1,
	    url: '/index/screendetails/pageBookRecords',
	    idParameter: "page",
	    ajaxData: {'pageType': 1},
	    beforeAjaxSubmit: function () {
	        PageAPI.AddAjaxData({"pageSize": $(".pageSize").val()});
	    },
	    ajaxSubmitBack: function (data) {
	        console.log(data);
	        $('.content2').empty();
	        var orderinfo = data.data;
	        console.log(orderinfo);
	        var infohtml='';	
	        if(orderinfo=='' ||orderinfo==undefined){
	            $(".content2").html(' <h2 style="text-align: center;padding-top:120px;height: 166px;color: red;background-color:#fff;">暂无数据</h2>');
	            $(".pagination3").hide();
	        }else{
	        	$(orderinfo).each(function(i,val){ 
	        		infohtml+='<div class="contents">';
			        infohtml+='<div class="booksWrap1">';
			        if (val.img&&val.img!='') {
				        infohtml+='<div class="booksImg"><img src="'+val.img+'" class="bookImg"></div>';
				    }else{
				        infohtml+='<div class="booksImg"><img src="/img/replace.jpg" class="bookImg"></div>';
				    }
			        infohtml+='<div class="booksName1">';
			        if (val.bname&&val.bname!='') {
			        	infohtml+='<span class="bookNameinfo1" title="《'+val.bname+'》">《'+val.bname+'》</span></div>';
			        }else{
			        	infohtml+='<span class="bookNameinfo1">暂无书名</span></div>';
			        }
			        infohtml+='<div class="booksPeople">';
			        if (val.uname&&val.uname!='') {
			        	infohtml+='<span class="booksPeopleinfo">借阅人：'+val.uname+'</span></div>'; 
			        }else{
			        	infohtml+='<span class="bookNameinfo1">暂无</span></div>';
			        }
					infohtml+='<div class="booksTime">';
					if (val.booktime&&val.booktime!='') {
			        	infohtml+='<span class="booksTimeinfo">借阅时间：'+val.booktime+'-'+val.expectedReturnTime+'</span></div>';
			        }else{
			        	infohtml+='<span class="booksTimeinfo">借阅时间：暂无</span></div>';
			        }
			        if(val.overtime&&val.overtime!=0){
			        	infohtml+='<div class="booksTime2">'; 
						infohtml+='<span class="booksPeopleinfo2">逾期时间：'+val.overtime+'天</span></div>'; 
			        }else{
			        	infohtml+='<div class="booksTime2">'; 
						infohtml+='<span class="booksPeopleinfo2">逾期时间：未归还</span></div>'; 
			        }
			        if(val.power==1&&val.states!=6){
			        	infohtml+='<div class="applyssBtn1">';
			        	infohtml+='<span class="applyssBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">申请归还</span></div>';
			        }else if(val.power==1&&val.states==6){
			        	infohtml+='<div class="applysssBtn1">';
			        	infohtml+='<span class="applysssBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">正在处理</span></div>';
			        }else if(val.type==1){
			        	infohtml+='<div class="applysBtn1">';
			        	infohtml+='<span class="applysBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">已预约(点击取消)</span></div>';
			        }else{
			        	infohtml+='<div class="applyBtn1">';
			        	infohtml+='<span class="applyBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">预约</span></div>';
			        }
			        infohtml+='</div></div>';
		        });
		        $(".content2").html(infohtml);
		        var info='<div class="clearfloat"></div>';
		        $(".content2").append(info);
		        $(".pagination3").show();
	        }

	    },
	    ajaxFormatBack: function (data) {
	        data.total = data.totalpage;
	        data.currentPage = data.currentPage;
	        
	    }
	});
}
</script>
<script>
//搜索书籍
$(".search_icon_container").click(function(){
	var bookName = $("#bname").val();
	// console.log(bookName);
	if(bookName==''){
		layer.msg('请填写图书名称！', {
            icon: 2,
            time: 1000
        }); 
	}else{
		$.ajax({
	        type: "POST",
	        url: "/index/index/search",
	        data: {'bname': bookName},
	        dataType: "json",
	        timeout: 3000,
	        success: function (data) {
	            console.log(data)
	            if(data==1){
	                window.location.href="/index/searchinfo/searchinfo/bname/"+bookName;
	            }else{
	            	layer.msg('没有该书籍！', {
	                    icon: 2,
	                    time: 1000
	                }); 
	            }
	        }
	    });
	}
})

</script>
<script>
//申请借阅
var bnum;
$(".content").on('click','.applyBtn',function(){
	bnum = $(this).index('.applyBtn');
	// alert(bnum);
	var bookid = $(this).find('input').val();
	// alert(bookid);
	$.ajax({
        type: "POST",
        url: "/index/screendetails/doapply",
        data: {'bookid': bookid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
    //         	layer.alert('已申请！', {
    //         	  icon: 6,
				//   skin: 'layer-ext-moon' //样式类名
				// }, function () {
    //             	var bhtml = '';
    //             	bhtml += '<div class="applysBtn">';
    //             	bhtml += '<span class="applysBtninfo"><input type="hidden" class="bookid" value="'+bookid+'">已申请(点击取消)</span></div>';
    //                 $(".applyBtn").eq(bnum).replaceWith(bhtml);
    //                 layer.close();
    //             });

                layer.msg('已申请！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applysBtn">';
                	bhtml += '<span class="applysBtninfo"><input type="hidden" class="bookid" value="'+bookid+'">已申请(点击取消)</span></div>';
                    $(".applyBtn").eq(bnum).replaceWith(bhtml);
                });
            }else{
                layer.msg('申请失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//取消申请
var bnums;
$(".content").on('click','.applysBtn',function(){
	bnums = $(this).index('.applysBtn');
	// alert(bnums);
	var bookid = $(this).find('input').val();
	// alert(bookid);
	$.ajax({
        type: "POST",
        url: "/index/screendetails/cancelapply",
        data: {'bookid': bookid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('取消成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applyBtn">';
                	bhtml += '<span class="applyBtninfo"><input type="hidden" class="bookid" value="'+bookid+'">申请借阅</span></div>';
                    $(".applysBtn").eq(bnums).replaceWith(bhtml);
                });
            }else{
                layer.msg('取消失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//预约书籍
var wantnum;
$(".content").on('click','.applyBtn1',function(){
	wantnum = $(this).index('.applyBtn1');
	// alert(wantnum);
	var booksid = $(this).find('input').val();
	$.ajax({
        type: "POST",
        url: "/index/screendetails/doapplys",
        data: {'bookid': booksid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('预约成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applysBtn1">';
                	bhtml += '<span class="applysBtninfo1"><input type="hidden" class="booksid" value="'+booksid+'">已预约(点击取消)</span></div>';
                    $(".applyBtn1").eq(wantnum).replaceWith(bhtml);
                });
            }else{
                layer.msg('预约失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//取消预约
var wantnums;
$(".content").on('click','.applysBtn1',function(){
	wantnums = $(this).index('.applysBtn1');
	var booksid = $(this).find('input').val();
	$.ajax({
        type: "POST",
        url: "/index/screendetails/cancelapplys",
        data: {'bookid': booksid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('取消成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applyBtn1">';
                	bhtml += '<span class="applyBtninfo1"><input type="hidden" class="booksid" value="'+booksid+'">预约</span></div>';
                    $(".applysBtn1").eq(wantnums).replaceWith(bhtml);
                });
            }else{
                layer.msg('取消失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//归还申请
var applyNum;
$('.content').on('click','.applyssBtn1',function(){
	applyNum = $(this).index('.applyssBtn1');
	var id = $(this).find('input').val();
	// alert(id);
	$.ajax({
	    type: "POST",
	    url: "/index/screendetails/applyrollback",
	    data: {'id': id},
	    dataType: "json",
	    timeout: 3000,
	    success: function (data) {
	        console.log(data)
	        if(data>=1){
	            layer.msg('申请已提交，请等待处理！', {
	                icon: 1,
	                time: 1000
	            }, function () {
	                var bhtml = '';
                	bhtml += '<div class="applysssBtn1">';
                	bhtml += '<span class="applysssBtninfo1"><input type="hidden" class="booksid" value="'+id+'">正在处理</span></div>';
                    $(".applyssBtn1").eq(applyNum).replaceWith(bhtml);
	            });
	        }else{
	            layer.msg('申请失败！', {
                    icon: 2,
                    time: 1000
                }); 
	       	}
	    }
    });
});
</script>
</html>